Class: DataMaps::Executable Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/data_maps/executable.rb

Overview

This class is abstract.

Base class for executables (converter, when, then)

Since:

  • 0.0.1

Direct Known Subclasses

Converter::Base, Then::Base, When::Base

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option) ⇒ Executable

Initializer

Parameters:

  • option (mixed)

    The given options

Since:

  • 0.0.1



13
14
15
16
17
# File 'lib/data_maps/executable.rb', line 13

def initialize(option)
  @option = option

  self.after_initialize if self.respond_to? :after_initialize
end

Instance Attribute Details

#@optionObject (readonly)

the given option

Returns:

  • (Object)

    the current value of @option



7
8
9
# File 'lib/data_maps/executable.rb', line 7

def @option
  @@option
end

#optionObject (readonly)

Since:

  • 0.0.1



8
9
10
# File 'lib/data_maps/executable.rb', line 8

def option
  @option
end

Class Method Details

.valid_collection?(collection) ⇒ Boolean

Helper method to check if all the executable in a collection are valid objects of self

Parameters:

  • collection (Array)

Returns:

  • (Boolean)

Since:

  • 0.0.1



29
30
31
# File 'lib/data_maps/executable.rb', line 29

def self.valid_collection?(collection)
  collection.is_a?(Array) && collection.all?{ |w| w.is_a?(self) }
end

Instance Method Details

#execute(data) ⇒ Object

The execute method to apply checks or mutations on the given data

Parameters:

  • data (mixed)

Raises:

  • (NotImplementedError)

Since:

  • 0.0.1



22
23
24
# File 'lib/data_maps/executable.rb', line 22

def execute(data)
  raise NotImplementedError.new("Please implement the execute method for your #{self.class.name}")
end